import { http } from '@/utils/http'
export interface LoginDto {
  username: string
  password?: string
  captcha?: string
  type: 'password' | 'captcha'
}
export interface RegisterDto {
  username: string
  nickname: string
  password: string
  confirmPassword: string
  email: string
  captcha: string
}

/** GET 请求 */
// export const getFooAPI = (name: string) => {
//   return http.get<LoginDto>('/foo', { name })
// }

/** POST 请求 */
export const login = <T>(data: LoginDto) => {
  return http.post<T>('/user/login', data)
}
export const sendLoginCaptcha = <T>(username: string) => {
  return http.get<T>('/user/send-user-login-captcha', { username })
}
export const registerCaptcha = <T>(address: string) => {
  return http.get<T>('/user/register-captcha', { address })
}
export const register = <T>(data: RegisterDto) => {
  return http.post<T>('/user/register', data)
}
